#include "fxcc/imgui/Editor.h"
#include "fxcc/core/Dir.h"
#include "fxcc/core/graph/common/EffectsDesc.h"
#include "fxcc/core/graph/common/ShaderLoader.h"

using namespace fxcc::graph::common;
using namespace fxcc::imgui;

template <>
bool Editor::Edit<EffectDesc>(const std::string& label, EffectDesc& inst)
{
    int index = 0;

    EditInst<fxcc::Base>("Base", inst);

    if (TreeNode("Effect", inst.m_ImguiFlag, index++))
    {
        EditInst<std::string>("m_Name", inst.m_Name);
        PathEditInst<std::string>("m_FragPath", inst.m_FragPath);
        EditInst<Defines>("m_Defines", inst.m_Defines);

        ImGui::Button("Drag");
        if (ImGui::BeginDragDropSource()) {

            EffectToken effectToken;
            effectToken.m_Key = inst.m_Name;

            ImGui::SetDragDropPayload("EffectToken", &effectToken, sizeof(effectToken));
            ImGui::Text("%s", inst.m_Name.c_str());
            ImGui::EndDragDropSource();
        }

        TreePop();
    }



    return false;
}


template <>
bool Editor::Edit<EffectsDesc>(const std::string& label, EffectsDesc& inst)
{
    int index = 0;
    if (TreeNode("m_Descs", inst.m_ImguiFlag, index++))
    {
        for (auto& desc : inst.m_Descs)
        {
            EditInst<EffectDesc>("Desc", desc);
        }

        if (ImGui::Button("+"))
        {
            inst.m_Descs.push_back({});
        }

        TreePop();
    }



    return false;
}
